﻿using System.Net.DnsToolkit.Packet;
namespace System.Net.DnsToolkit.Serializer {

    /// <summary>
    /// Read DNS Message from source object
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IMessageReader<T> {

        /// <summary>
        /// Read source object into message throws exception if problem occurs
        /// </summary>
        /// <param name="source"></param>
        /// <returns>message to be read</returns>
        IMessage Read(T source);

        /// <summary>
        /// Read source object into message. Do not throw exception.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="message"></param>
        /// <returns>true if no error occured, else false.</returns>
        bool TryRead(T source, out IMessage message);

    }

}
